package com.rajaev.dtu.tractor.interfaces;

import com.rajaev.dtu.tractor.app.service.BatteryService;
import com.rajaev.dtu.tractor.domain.vo.BatteryMonitorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 电池监控信息的控制器
 * @author tianjie
 */
@RestController
public class BatteryMonitorController {

    @Autowired
    BatteryService batteryService;


    /**
     * 根据vin后四位查询电池信息
     * @param last4vin
     * @return
     */
    @GetMapping("/batteryMonitor/selectBatteryMonitors")
    public List<BatteryMonitorVo> selectBatterMonitor(String last4vin,
                                                      @RequestParam(defaultValue = "10") Integer pageSize,
                                                      @RequestParam("pageNum") Integer pageNum){
        return batteryService.selectByLastVin4(last4vin,pageSize,pageNum);
    }

    /**
     * 从数据库中删除该电池的数据
     * @param vin
     */
    @PostMapping("/battery/deleteVin")
    public void deleteBattery(String vin){
        batteryService.delete(vin);
    }

    /**
     * 补录车辆-vin
     * @param vin vin
     */
    @PostMapping("/battery/additionSave")
    public void batterSave(String vin){
        batteryService.save(vin);
    }



   /* @GetMapping("/battery/historyTrack")
    public List<HistoryTrackVo> getHistoryTrack(String vin,
                                                @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date fromDate,
                                                @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endDate, HttpServletResponse response){
        return batteryService.getHistoryTrack(vin, fromDate, endDate,response);
    }*/


}
